package com.pxx.item.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pxx.item.pojo.TbSpecParam;
import com.pxx.item.service.TbSpecParamService;
import com.pxx.item.mapper.TbSpecParamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Yoo19
* @description 针对表【tb_spec_param(规格参数组下的参数名)】的数据库操作Service实现
* @createDate 2025-06-26 18:25:18
*/
@Service
public class TbSpecParamServiceImpl extends ServiceImpl<TbSpecParamMapper, TbSpecParam>
    implements TbSpecParamService{

    @Autowired
    private TbSpecParamMapper tbSpecParamMapper;

    @Override
    public List<TbSpecParam> queryParams(Long gid, Long cid, Boolean generic, Long searching) {

        QueryWrapper<TbSpecParam> queryWrapper = new QueryWrapper<>();
        if(gid != null){
            queryWrapper.eq("group_id",gid);
        }
        if(cid != null){
            queryWrapper.eq("cid",cid);
        }
        if(generic != null){
            queryWrapper.eq("generic",generic);
        }
        if(searching != null){
            queryWrapper.eq("searching",searching);
        }

        return tbSpecParamMapper.selectList(queryWrapper);
    }

    @Override
    public void queryAddParam(TbSpecParam specParam) {
        tbSpecParamMapper.insert(specParam);
    }

    @Override
    public void queryDeleteParam(Long id) {
    tbSpecParamMapper.deleteById(id);
    }

    @Override
    public void queryUpdateParam(TbSpecParam specParam) {
        tbSpecParamMapper.updateById(specParam);
    }
}




